<?php
include "method/win.php";
if(isset($_POST['submit'])){
    if($_SESSION['code']!=$_POST['checkcode']){
        show_msg("验证码错误!", "login.php");
    }else{
        login($_POST['username'],md5($_POST['password']));
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>小狗微博登录页面</title>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.css">

</head>
<body>
<script type="text/javascript">
function check(){
	if(myform.username.value==""){
		alert("用户名不能为空!");
		return false;
	}
	if(myform.username.value.length < 2 || myform.username.length > 10){
		alert("用户名长度要在2到10位之间");
		return false;
	}
	if(myform.password.value=="" ){
		alert("密码不能为空!");
		return false;
	}
	if(myform.password.value.length < 3 || myform.password.value.length > 10 ){
		alert("密码长度应为3到10");
		return false;
	}
	if(myform.checkcode.value=="" ){
		alert("验证码不能为空!");
		return false;
	}
	return true;
}
</script>
<form id="myform" class="well" method="post" name="myform" onsubmit="return check()" action=""
      style="width: 30em; margin: auto; margin-top: 150px;">
    <h3>用户登录</h3>
    <div class=" input-group input-group-md">
              <span class="input-group-addon" id="sizing-addon1"><i
                      class="glyphicon glyphicon-user" aria-hidden="true"></i></span> <input
            id="userName" type="text" class="form-control" placeholder="用户名"
            aria-describedby="sizing-addon1" name="username"/>
    </div>
    <br/>
    <div class="input-group input-group-md">
              <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
        <input type="password"
               id="password" class="form-control"
               placeholder="密码"
               aria-describedby="sizing-addon1"
               name="password"/>
    </div>
    <br/>
    <div class="input-group input-group-md">
    <input type="text"
               id="checkcode" class="form-control" name="checkcode"
               placeholder="验证码"
               aria-describedby="sizing-addon1"
               style="float: left"/>
        <span class="input-group-addon" style="padding: 0">
        	<img height=25 id="img_code" src="method/checkcode.php" onclick="this.src=this.src+'?'+Math.random()" ></i>
        </span>
    </div>
    <div id="error_box"><br></div>
    <button type="submit" class="btn btn-success btn-block" name="submit">登录</button>
	<a class="btn btn-sm btn-white btn-block" style="text-align: right;" href="findpw.php"><h6>忘记密码？</h6></a>
    <a class="btn btn-sm btn-white btn-block" style="text-align: right;" href="register.php"><h6>还没有账户？前往注册</h6></a>
</form>
</body>
</html>
